<%-- 
    Document   : index
    Created on : Feb 27, 2014, 6:26:56 PM
    Author     : ADMIN
--%>

<%@page import="java.util.ArrayList"%>
<%@page import="entity.Item"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>

<html>
    <%
        String country = request.getParameter("country");
        ArrayList<Item> list = (ArrayList<Item>) request.getAttribute("list");
        Item item = new Item();
        if (list == null) {
            out.print("null abc");
        } else {
            out.print("not null bcd");
        }
    %>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <h1>View Weather by Country</h1>
        <form action="getWeatherServlet">
            <table style="border: solid red">
                <tr>
                    <td>
                        Country
                    </td>
                    <td>
                        <c:if test="<%= country == null%>">
                            <input name="country" value=""/>
                        </c:if>
                        <c:if test="<%= country != null%>">
                            <input name="country" value="<%= country%>"/>
                        </c:if>

                    </td>
                </tr>               
                <tr>
                    <td>
                        <input type="submit" value="Find Country">
                    </td>
                    <td>
                    </td>
                </tr>
            </table> 
        </form>
        <br/>
        <form action="getWeatherServlet1">
            <table style="border: solid blue">
                <tr>
                    <td>
                        City <input type="hidden" name="country" value="<%= country%>"/>
                    </td>
                    <td>
                        <select name="city">
                            <c:if test="<%= list != null%>">
                                <c:forEach items="<%= list%>" var="name" >
                                    <option>${name.getCity()}</option>
                                </c:forEach>                               
                            </c:if>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td>
                        <input type="submit" value="View Weather">
                    </td>
                    <td>
                    </td>
                </tr>
            </table> 
        </form>
    </body>
</html>
